Skip to content

Use git CLI for version metadata#2709

Merged
riccardobl merged 1 commit into
jMonkeyEngine:masterfrom
8Keep:git-cli-version-metadata
May 9, 2026
Merged

Use git CLI for version metadata#2709
riccardobl merged 1 commit into
jMonkeyEngine:masterfrom
8Keep:git-cli-version-metadata

Conversation

@8Keep
Copy link
Copy Markdown
Contributor

@8Keep 8Keep commented Apr 16, 2026

The author of the gradle plugin we use (that uses jgit) has abandoned it, saying it's easy to just use git cli from gradle directly: https://andrewoberstar.com/posts/2024-04-02-dont-commit-to-grgit/

I ran into a broken version info when trying to speed up the gradle builds, because I use git worktrees to get work done, and jgit doesn't seem to support git worktrees. So this enables new AI native functionality: many git worktrees for different workstreams in parallel, too.

Split out from #2701

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the grgit library with direct Git command execution using Gradle's providers.exec to retrieve versioning metadata. The changes include removing the gradle-git dependency and refactoring version.gradle to use a new gitOutput helper. A review comment identifies a potential issue where jmeBranchName could be overwritten with an empty string if Git commands fail, suggesting a fallback to the default 'unknown' value.

Comment thread version.gradle Outdated
@8Keep 8Keep force-pushed the git-cli-version-metadata branch from be27733 to 63c4913 Compare April 16, 2026 00:36
@8Keep 8Keep marked this pull request as ready for review April 16, 2026 00:37
@8Keep
Copy link
Copy Markdown
Contributor Author

8Keep commented Apr 16, 2026

Ready for review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 16, 2026

🖼️ Screenshot tests have failed.

The purpose of these tests is to ensure that changes introduced in this PR don't break visual features. They are visual unit tests.

📄 Where to find the report:

⚠️ If you didn't expect to change anything visual:
Fix your changes so the screenshot tests pass.

If you did mean to change things:
Review the replacement images in jme3-screenshot-tests/build/changed-images to make sure they really are improvements and then replace and commit the replacement images at jme3-screenshot-tests/src/test/resources.

If you are creating entirely new tests:
Find the new images in jme3-screenshot-tests/build/changed-images and commit the new images at jme3-screenshot-tests/src/test/resources.

Note; it is very important that the committed reference images are created on the build pipeline, locally created images are not reliable. Similarly tests will fail locally but you can look at the report to check they are "visually similar".

See https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-screenshot-tests/README.md for more information

Contact @richardTingle (aka richtea) for guidance if required

@8Keep
Copy link
Copy Markdown
Contributor Author

8Keep commented Apr 16, 2026

@richardTingle it seems like the screenshot tests are very flaky recently.

@riccardobl
Copy link
Copy Markdown
Member

@gemini-code-assist review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the grgit library with direct Git command execution using Gradle's providers.exec to retrieve versioning information, effectively removing the gradle-git dependency. The logic for determining the revision, branch name, and tags has been refactored to use shell commands. Review feedback suggests improving the robustness of the version tag extraction and adjusting the regex for matching Git hashes to account for potential length variations in git describe output.

Comment thread version.gradle Outdated
Comment thread version.gradle Outdated
@8Keep 8Keep force-pushed the git-cli-version-metadata branch from 2c25661 to 2b4999f Compare May 8, 2026 21:26
@8Keep
Copy link
Copy Markdown
Contributor Author

8Keep commented May 8, 2026

@riccardobl should be good now

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the build’s version-metadata extraction (revision, hashes, branch, tags) from the abandoned Grgit/JGit-based approach to invoking the system git CLI directly, improving compatibility with Git worktrees and simplifying Gradle dependencies.

Changes:

  • Remove Grgit (org.ajoberstar:gradle-git) usage and its buildscript classpath setup.
  • Add a gitOutput(...) helper using providers.exec and use it to populate jmeRevision, jmeGitHash, jmeShortGitHash, jmeBranchName, and tag info.
  • Remove the gradle-git entry from gradle/libs.versions.toml.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
version.gradle Switch version metadata discovery from Grgit to git CLI invocations.
gradle/libs.versions.toml Remove the unused gradle-git dependency version entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread version.gradle Outdated
Comment thread version.gradle Outdated
@8Keep 8Keep force-pushed the git-cli-version-metadata branch from caf1a1d to c76826c Compare May 9, 2026 17:58
@riccardobl riccardobl merged commit 4e18b18 into jMonkeyEngine:master May 9, 2026
24 of 25 checks passed
@8Keep 8Keep deleted the git-cli-version-metadata branch May 9, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants